#include <fstream>
#include <iostream>

using namespace std;

int main()
{
    char data[100];

    ofstream outFile;
    outFile.open("test.data");

    cout << "write to the file" << endl;
    cout << "enter your name" << endl;

    cin.getline(data, 100);
    outFile << data << endl;

    cout << "enter your age" << endl;
    cin >> data;
    cin.ignore;

    outFile << data << endl;
    outFile.close();

    ifstream infile;
    infile.open("test.data");

    cout << "Reading from the file" << endl;
    infile >> data;

    cout << data << endl;
    infile >> data;
    cout << data << endl;
    infile.close();
    return 0;
}